Server Variables, Functions and Commands

Server Variables

The following table describes the server variables you can use at certain places within the system.

Please be aware that not all variables are applicable or available for all areas of the server.

Variable

Returns

%%From%%

whole From header of the message

%%From_Email%%

first email address from the From header

%%From_Alias%%

alias part of the first email address from the From header

%%From_Domain%%

domain part of the first email address from the From header

%%From_Name%%

name taken from the From header; (performed as string before the first < character)

%%To%%

whole To header of the message

%%To_Email%%

first email address from the To header

%%To_Alias%%

alias part of the first email address from the To header

%%To_Domain%%

domain part of the first email address from the To header

%%To_Name%%

name taken from the To header; (performed as string before the first < character)

%%Sender%%

sender of the message (whole content of MAIL FROM: command, even with < and >)

%%Sender_Email%%

email address of the sender (without < and >)

%%Sender_Alias%%

alias part of senders email address

%%Sender_Domain%%

domain part of senders email address

%%Recipient%%

list of all recipients delimited with semicolon ((whole content of RCPT TO: commands, even with < and >)

%%Current_Recipient%%

email address of the current recipient - the address of the account being processed

%%Recipient_Email%%

email address of first recipient of the message

%%Recipient_Alias%%

alias part of email address of first recipient of the message

%%Recipient_Domain%%

domain part of email address of first recipient of the message. If empty, primary domain is returned.

%%Extension%%

Extension of the recipient email address containing the extension separator

%%ExtensionNoSep%%

Extension of the recipient email address without separator

%%Subject%%

Subject of the message

%%Message-ID%%

Message-ID of the message (even with < and >)

%%Date%%

current date

%%Time%%

current time

%%Header%%

all headers of the message

%%Body%%

body of the message in plain text

%%Body MaxSize%%

body of the message in plain text limited to MaxSize

%%Body_HTML%%

body of the message in HTML (if any)

%%Body_HTML MaxSize%%

body of the message in HTML limited to MaxSize (if any)

%%Size%%

size of the message in kB

%%IP%%

IP address of the sender

%%UniqueID%%

Unique ID string (md5 random hash)

%%RFC822_Date%%

date and time of message arrival in RFC822 format, based on server time and GMT offset

%%AttachmentNames%%

names of the attachments delimited with semicolon
Use rarely. Requires a high CPU usage and processing time.

%%Header HeaderItem%%

particular message header.
Eg: %%Header X-Mailer%%

%%Include FileName%%

includes content of the filename. See the example at the end of the <install_dir>/examples/variables.dat file. The file itself can contain server variables.

%%Include_Base64 FileName%%

includes filename in Base64 encoding. See the example at the end of the <install_dir>/examples/variables.dat file.

%%MessageFile%%

filename (.tmp or .imap file) storing actual content of the message

%%Copy HeaderItem Position Length%%

copy Length characters of HeaderItem from Position (Position is zero based)

%%Delete HeaderItem Position Length%%

delete Length characters of HeaderItem from Position (Position is zero based)

%%FormatDateTime Format%%

formated date of the message
Eg: Today is %%FormatDateTime yyyy-mm-dd hh:nn:ss%%

%%VirusName%%

names of the viruses (within the message) delimited with semicolon

%%VirusDBDate%%

last update date of the database for IceWarp antivirus engine

%%SpamScore%%

result of antispam filters

%%SpamReason%%

reason why message has been marked as spam

%%MailboxPath%% %%Mailbox%% %%Alias%%

account variables used only in certain places

%%Forward_recipients Host#port%%

list of all recipients prepared for relay to the given Host, delimited with semicolons

Eg: %%Forward_recipients mail.domain.com%% > @mail.domain.com:r1@xx.com;@mail.domain.com:r2@xy.com;

This variable (and the two following ones) are valid in every place, where %%Recipient%% is valid.

%%Forward_local_recipients Host#port%%

similar to %%Forward_recipients%%, but only local accounts are added to the output

%%Forward_domain_recipients Host#port;domain1;domain2%%

similar to %%Forward_recipients%%, but only recipients from given domains are added to the output

%%Auth_Emai%%

email address of the authenticated user (without < and >), or empty if nobody authenticated

%%Auth_Username%%

username of the authenticated user (without < and >), or empty if nobody authenticated

%%vcard FIELD%%

vCard variable of message sender specified by FIELD.
Following algorithm is used to identify user whose vCard data should be used:

  • "From" header of the message is matched against local account

  • if no match found, SMTP Sender of the message is matched against local account

  • if no match found, user account used during SMTP authentication is used

  • if no SMTP authentication, %%vcard%% variables will be replaced by empty string

Example:

%%vcard FN%%, %%vcard TITLE%%

%%vcard FIELD#ATTR~VAL%%

This is extended variant of the previous %%vcard option. It is usable when the relevant field may appear more then once in the VCARD. You can specify attribute name and a value which will be searched in that attribute (fulltext). E.g. %%VCARD TEL#TYPE~WORK%%, %%VCARD TEL#TYPE~HOME%%

%%Secure_Connection%%

"1" or "0" indicates if connection is secured (either via direct SSL, or using STARTTLS)

%%BCC_Recipient%%

list of recipients not present in TO: or Cc: headers, delimited with semicolon(s) (even with < and >). If this variable is used in content filter during "copy incoming/outgoing mail" operation (using the "apply content filter" option), original email recipients are used, not the recipients where the message is being copied to.

%%PORT%%

port of the sender

%%Local_IP%%

active local IP address

%%Local_PORT%%

active local port

%%RFC822_Date Num%%

date and time Num seconds in the future in RFC822 format, based on server time and GMT offset

e.g: %%RFC822_Date 60%%

%%SpamProbability%%

SPAM probability returned from Bayesian filter

%%SpamPercentage%%

SPAM probability returned from Bayesian filter in percent units

%%SpamHits%%

total message SPAM score

%%PhoneAlias%%

phone alias of user

%%InstallPath%%

path to server installation directory

%%Temp%%

contains last fetched line from client, suitable for Milter filters

%%Exec CommandPath%%

variable is replaced by string returned by executable at CommandPath

Server Functions

The following table describes the server functions you can use at certain places within the system. These functions are similar to server variables but are more complex than simple variables.

Please be aware that not all functions are applicable or available for all areas of the server.

Server Commands

These special extended variable commands work only for Auto Responders and Content Filter message actions.

See examples:

Example #1 (Simple Auto Responder):

Hello, I received your your message at %%Time%% on the %%Date%% and the size was %%Size%% kB.

Example #2 Advanced Auto Responder With an Attachment:

Works only for Content Filters with "Send message" or "Reply with message" actions (not for normal AutoResponders, because of security).

$$SetSubject Message Subject: %%Subject%%$$

$$SetPartBoundary --BoundaryXX$$

----BoundaryXX

Content-Type: text/plain

This is the text part of the message. The following part contains an attachment image.

----BoundaryXX

Content-Type: application/octet-stream; name="image.gif"

Content-Transfer-Encoding: base64

%%Include_Base64 c:\temp\image.gif%%

----BoundaryXX

Example #3 (Message Containing only Attachment):

Works for Content filters only

$$SetHeader Content-Type: application/octet-stream; name="filename.ext"$$$$SetHeader Content-Transfer-Encoding: base64$$

%%Include_Base64 d:\daily.txt%%

Example #4 (Virus Warning):

Warning: Virus '%%VirusName%%' detected. Message was rejected.

Message's header:

%%Header%%

Example #5 Advanced Auto Responder With an Embedded Image:

Works only for Content Filters with "Send message" or "Reply with message" actions (not for normal AutoResponders, because of security).

$$SetSubject Message Subject: %%Subject%%$$

$$SetPartBoundary --BoundaryXX$$

----BoundaryXX

Content-Type: text/html; charset=UTF-8

Content-Transfer-Encoding: quoted-printable

<body>This is the text part of the message. The following part contains an attachment image.<br><img src="cid:1426452f24b5a097155.71010193"></body>

----BoundaryXX

Content-Type: image/gif; name="image.gif"; charset="UTF-8";

Content-Transfer-Encoding: base64

Content-ID: <1426452f24b5a097155.71010193>

Content-Disposition: inline; filename="image.gif"

%%Include_Base64 <path_to_image>%%

----BoundaryXX